<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增锜风公寓-房间住客')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-guest-add">
            <div class="col-xs-12">
                <div class="form-group">
                    <div class="col-sm-8">
                        <!-- 1. type="hidden" 隐藏输入框 -->
                        <!-- 2. th:value="${room.roomId}" 自动回填控制器传递的roomId -->
                        <!-- 3. required 保留（确保提交时能传值到后端） -->
                        <input name="roomId" class="form-control" type="hidden" th:value="${room.roomId}" required>
                    </div>
                </div>
            </div>
            <!-- 房间号：可见但不可修改，自动回填 -->
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">房间号：</label>
                    <div class="col-sm-8">
                        <!-- 1. readonly 使输入框不可编辑（用户无法修改） -->
                        <!-- 2. th:value="${room.roomNum}" 自动回填房间号 -->
                        <!-- 3. 保留 type="text" 确保用户可见 -->
                        <input name="roomNum" class="form-control" type="text" th:value="${room.roomNum}" readonly required>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">单元号：</label>
                    <div class="col-sm-8">
                        <!-- 后端接收的字段名，必须和原select的name一致 -->
                        <input type="hidden" name="unit" th:value="*{room.unit}">  <!-- 回显单元号的值，确保提交正确 -->
                        <!-- 2. 禁用的占位下拉框：仅用于显示，不参与提交 -->
                        <select name="unit" class="form-control m-b" th:with="type=${@dict.getType('qif_room_unit')}" disabled  required>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{room.unit}" ></option>
                        </select>
                        </select>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">姓名：</label>
                    <div class="col-sm-8">
                        <input name="guestName" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">性别：</label>
                    <div class="col-sm-8">
                        <select name="guestSex" class="form-control m-b" th:with="type=${@dict.getType('sys_user_sex')}">
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">身份证号：</label>
                    <div class="col-sm-8">
                        <input name="guestIdNumber" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">身份地址：</label>
                    <div class="col-sm-8">
                        <input name="guestAddress" class="form-control" type="text"></input>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">照片：</label>
                    <div class="col-sm-8">
                        <input name="guestPhoto" class="form-control" type="text"></input>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">民族：</label>
                    <div class="col-sm-8">
                        <input name="guestEthnicity" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">状态：</label>
                    <div class="col-sm-8">
                        <select name="status" class="form-control m-b" th:with="type=${@dict.getType('qif_guest_status')}">
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">入住时间：</label>
                    <div class="col-sm-8">
                        <div class="input-group date">
                            <input name="checkInTime" class="form-control" placeholder="yyyy-MM-dd" type="text">
                            <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">备注：</label>
                    <div class="col-sm-8">
                        <textarea name="remark" class="form-control"></textarea>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var prefix = ctx + "qif/guest"
        $("#form-guest-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-guest-add').serialize());
            }
        }

        $("input[name='checkInTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
    </script>
</body>
</html>